package dyyx.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Date;
import java.util.List;

import dyyx.util.JdbcUtil;

public class SystemDBInfo {

	public static void main(String[] args) throws Exception {
		
		System.out.println("hello,clickhouse NativeJdbc,"+new Date());	
		
		// Class.forName("com.github.housepower.jdbc.ClickHouseDriver");
		
		// com.github.housepower.jdbc.ClickHouseDriver
		// ru.yandex.clickhouse.ClickHouseDriver
		// 8123  
		// Port 9000 is for clickhouse-client program. You must use port 8123 for HTTP.
		// 两个 driver 同时存在 ， 匹配第一个
		String url = "jdbc:clickhouse://10.57.31.23:8123/system";
		System.out.println("url="+url);	
		
		System.out.println("driver="+DriverManager.getDriver(url));	

		Connection connection = DriverManager.getConnection(url,"default","");

		Statement stmt = connection.createStatement();
		System.out.println("stmt="+stmt);	
		
		// ResultSet rs = null;
		
		String sql = "use system";


		// 使用 system db
		// System.out.println("\n\n use db,system");

		// sql = "use system";
		// System.out.println(stmt.execute(sql));
		
		
		sql = "show tables";
		
		List<String> tables = JdbcUtil.queryStringList(connection, sql);
		System.out.println("tables="+tables);	
		
		
		
		// rs.close();
		// stmt.close();
		// connection.close();
		
		    
		
	}
}
